package Model;

import java.io.Serializable;
import java.util.ArrayList;


/**
 * Created with IntelliJ IDEA.
 * User: Anastasia
 * Date: 25.11.14
 * Time: 21:03
 * To change this template use File | Settings | File Templates.
 */
public class Model implements Serializable{

    private ArrayList<Employee> list;
     
    public Model()
    {
        list = new ArrayList<Employee>() ;
    }

    public void setList(ArrayList<Employee> list)
    {
        this.list = list;
    }
    
    public ArrayList<Employee> getList()
    {
         return list;
    }

    public void addEmployee(Employee emp)
    {
        list.add(emp);
    }

    public void deleteEmployeeById(int id)
    {
        list.remove(id);
    }

    public Employee getEmployeeById(int id)
    {
        return list.get(id);
    }

    public void setEmployeeByIndex(int id, Employee emp)
    {
        list.set(id, emp) ;
    }

    public void printModel()
    {
        for(int i=0;i<list.size();i++)
        {
            System.out.println("Сотрудник № "+(i+1));
            System.out.println("Имя: "+list.get(i).getName());
            System.out.println("Отчество: "+list.get(i).getMiddleName());
            System.out.println("Фамилия: "+list.get(i).getLastName());
            System.out.println("Отдел: "+list.get(i).getDepartment().getName());
            System.out.println("Зарплата: "+list.get(i).getPay());
            System.out.println("Телефон: "+list.get(i).getPhoneNumber());
        }
    }

    public int getCount()
    {
        return list.size();
    }

}
